<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="gradeHoraria" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{gradeHorariaHome.managed ? 'Edit' : 'Add'} Grade horaria</f:facet>


            <s:decorate id="idtGradeHorariaField" template="layout/edit.xhtml">
                <ui:define name="label">Idt grade horaria</ui:define>
                <h:inputText id="idtGradeHoraria"
                       required="true"
                       disabled="#{gradeHorariaHome.managed}"
                          value="#{gradeHorariaHome.instance.idtGradeHoraria}">
                    <a:support event="onblur" reRender="idtGradeHorariaField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{gradeHorariaHome.persist}"
                       disabled="#{!gradeHorariaHome.wired}"
                       rendered="#{!gradeHorariaHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{gradeHorariaHome.update}"
                       rendered="#{gradeHorariaHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{gradeHorariaHome.remove}"
                      immediate="true"
                       rendered="#{gradeHorariaHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/GradeHoraria.xhtml"
                rendered="#{gradeHorariaHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty gradeHorariaFrom ? 'GradeHorariaList' : gradeHorariaFrom}.xhtml"
                rendered="#{!gradeHorariaHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Turma *" labelClass="required">
    <div class="association" id="turmaParent">

        <h:outputText value="There is no turma associated with this gradeHoraria."
                   rendered="#{gradeHorariaHome.instance.turma == null}"/>

        <rich:dataTable var="_turma"
                   value="#{gradeHorariaHome.instance.turma}"
                rendered="#{gradeHorariaHome.instance.turma != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="turmaTable">
            <h:column>
                <f:facet name="header">Idt turma</f:facet>
                <h:outputText value="#{_turma.idtTurma}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Grade curricular idt grade curricular</f:facet>
                <h:outputText value="#{_turma.gradeCurricular.idtGradeCurricular}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Cod turma</f:facet>
                <h:outputText value="#{_turma.codTurma}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Num ano</f:facet>
                <h:outputText value="#{_turma.numAno}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Num periodo vigente</f:facet>
                <h:outputText value="#{_turma.numPeriodoVigente}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Num semestre</f:facet>
                <h:outputText value="#{_turma.numSemestre}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{gradeHorariaHome.instance.turma != null ? 'changeParent' : 'selectParent'}" value="#{gradeHorariaHome.instance.turma != null ? 'Change' : 'Select'} turma"
                       view="/TurmaList.xhtml">
                <f:param name="from" value="GradeHorariaEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Grade horaria items">
        <h:form styleClass="association" id="gradeHorariaItemsChildren">

            <h:outputText value="There are no gradeHorariaItems associated with this gradeHoraria."
                       rendered="#{empty gradeHorariaHome.gradeHorariaItems}"/>

            <rich:dataTable value="#{gradeHorariaHome.gradeHorariaItems}"
                           var="_gradeHorariaItem"
                      rendered="#{not empty gradeHorariaHome.gradeHorariaItems}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="gradeHorariaItemsTable">
                <rich:column sortBy="#{_gradeHorariaItem.idtGradeHorariaItem}">
                    <f:facet name="header">Idt grade horaria item</f:facet>
                    <h:outputText value="#{_gradeHorariaItem.idtGradeHorariaItem}"/>
                </rich:column>
                <rich:column sortBy="#{_gradeHorariaItem.indDiaSemana}">
                    <f:facet name="header">Ind dia semana</f:facet>
                    <h:outputText value="#{_gradeHorariaItem.indDiaSemana}"/>
                </rich:column>
                <rich:column sortBy="#{_gradeHorariaItem.numHoraFim}">
                    <f:facet name="header">Num hora fim</f:facet>
                    <h:outputText value="#{_gradeHorariaItem.numHoraFim}">
                        <s:convertDateTime type="time"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_gradeHorariaItem.numHoraInicio}">
                    <f:facet name="header">Num hora inicio</f:facet>
                    <h:outputText value="#{_gradeHorariaItem.numHoraInicio}">
                        <s:convertDateTime type="time"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{gradeHorariaHome.managed}" id="gradeHorariaItems">
        <div class="actionButtons">
            <s:button id="addgradeHorariaItem"
                   value="Add gradeHorariaItem"
                    view="/GradeHorariaItemEdit.xhtml"
             propagation="none">
                 <f:param name="gradeHorariaIdtGradeHoraria"
                         value="#{gradeHorariaHome.instance.idtGradeHoraria}"/>
                 <f:param name="gradeHorariaItemFrom" value="GradeHoraria"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
